home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / dcgames4.zip / WORLDDEF.SCR < prev    next >
Text File  |  1995-10-02  |  6KB  |  148 lines

  1. !
  2. ! FILE: WORLDDEF.SCR
  3. !
  4. ! Entering a world is a complicated sequence of events...
  5. !
  6. ! a) It starts when the player decides to ENTER a door, falls
  7. !    through a trap-door or somehow enters a door.  This happens
  8. !    usually in the CONTROL script.
  9. !
  10. ! b) The control script uses 'RUNSCRIPT' to execute the world's
  11. !    script (WORLDnnn.SCO) if it exists, at entry ponit @EXIT
  12. !    to allow that script to handle EXITing the current world.
  13. !
  14. ! c) If the WORLDnnn file does not exist, or it exists but
  15. !    it ends with CONTINUE instead of STOP, the WORLDDEF
  16. !    script is executed (this one) at the @EXIT entry point.
  17. !
  18. ! d) This script displays the EXITTEXT associated with the 
  19. !    door and then calls ENTER() followed by CONTINUE, which
  20. !    tells the driver to discard the current world and load
  21. !    the new one.
  22. !
  23. ! e) The driver discards the current world, loads the new one,
  24. !    then:
  25. !
  26. ! f) It calls the new world's WORLDnnn script (if it exists) 
  27. !    at entry point @GET, to allow that script to "interfere"
  28. !    with the entry.  If this script calls ENTER() or some
  29. !    of the other transfers (like TELEPORT()), the new world
  30. !    will be loaded and it's @GET script called, until one of
  31. !    scripts ends without calling ENTER, etc.
  32. !    NOTE THAT THE OLD WORLD, WHILE NO LONGER LOADED, IS STILL
  33. !    DISPLAYED IN THE VIEW PORT. THE PLAYER HAS NOT SEEN THE
  34. !    DESTINATION WORLD AT THIS POINT.
  35. !
  36. ! g) If the previous script didn't exist or it ended with 
  37. !    CONTINUE (but without calling ENTER, etc.) the WORLDDEF
  38. !    script is called to handle the transfer in the @GET entry
  39. !    point.  This default script doesn't do anything with 
  40. !    that call. It just 'CONTINUE's.
  41. !
  42. ! h) THE DRIVER NOW DISPLAYS THE NEW WORLD IN THE VIEWPORT.
  43. !
  44. ! i) Now the driver calls the WORLDnnn script at entry point
  45. !    @ENTER.
  46. !
  47. ! j) If the above script ends with CONTINUE on the second call,
  48. !    or the script does not exist at all, then the default script
  49. !    (WORLDDEF) is called with entry pont @ENTER.
  50. !
  51. ! NOTES:
  52. !
  53. !  1) The main purpose of the @GET entry point is to allow you to 'catch'
  54. !     the player BEFORE the new world is displayed.  The main reason for
  55. !     this is that you may want to transfer the party to a 3rd destination
  56. !     upon certain conditions.  Should you perform a transfer in the @ENTER
  57. !     section, the new world would 'blink' on the screen, before the party
  58. !     is transfered.  This MAY very well be what you want to do, for example
  59. !     if you display some text or do some animation that shows the reason
  60. !     why the final destination will be different!.
  61. !
  62. ! (c) DC Software, 1995
  63. !
  64.  
  65. !------------------------------------------------------------------------!
  66. :@GET  ! CALLED FROM THE DRIVER BEFORE THE NEW WORLD IS LOADED
  67. !------------------------------------------------------------------------!
  68.   L1 = group.current;
  69.   group.current = 0;
  70.   if player.level < world.level then
  71.     group.current = L1;
  72.     writeln( "You are not experienced enough to go in there.." );
  73.     enter(world.door); ! Go back the way we came.. !
  74.     stop;
  75.   endif;
  76.   group.current = L1;
  77.   continue;
  78.  
  79. !------------------------------------------------------------------------!
  80. :@ENTER   ! CALLED FROM THE DRIVER AFTER THE WORLD IS "displayed"
  81. !------------------------------------------------------------------------!
  82.   L0 = 0; 
  83.   if world.entrytext(world.door) > 0 then
  84.     readtext( world.entrytext(world.door) );
  85.     ! if the switch is zero, the text is displayed only once !
  86.     if world.entrytextswitch(world.door) = 0 then 
  87.       world.entrytext(world.door) = -1; ! Forget the text !
  88.     endif;
  89.     L0 = 1;  ! Text has been displayed !
  90.   endif;
  91.  
  92.   ! For compatibility with version 1.0 and 2.0, handle the end-game flag !
  93.   if world.type = ENDGAME then
  94.     writeln( "Press <SPACE> to end game" );
  95.     pause; ! Wait before ending the game !
  96.     ENDGAME;
  97.   endif;
  98.  
  99.   if L0 = 0 then
  100.     writeln( "You are now in ", world.name );
  101.   endif;
  102.  
  103.   if world.type = ARENA then
  104.     ! Create a RANDOM monster in the center of this world !
  105.     L2 = random(3);                       ! SIZE 0=Small, 1=Medium, 2=Large 
  106.     L3 = random(L2+3);                    ! Tile # 0-2, 1-3 or 2-4 !
  107.     new( npc, world.x / 2, world.y / 2, defcaveblk(L3) );
  108.  
  109.     npc.type   = HOSTILE;                 ! NPC Type
  110.     npc.stats  = defstat(CAVE_MONSTER);   ! Statistics Record
  111.     npc.class  = CAVE_MONSTER;            ! Monster Class
  112.     npc.block2 = npc.block;               ! Followers are the same tile..
  113.     npc.value  = 0;                       ! No money;
  114.  
  115.     !
  116.     ! # of monsters in the group.  The formula is based on L2 (monster size).
  117.     ! If small  (L2=0), then # = random( group.size + 6 ) + 1
  118.     ! If medium (L2=1), then # = random( group.size + 3 ) + 1
  119.     ! if large  (L2=2), then # = random( group.size ) + 1
  120.     npc.count = random( group.size + (2 - L2) * 3 ) + 1;
  121.     
  122.   endif;
  123.   STOP; ! Ok.  We have 'entered' the world !
  124.  
  125. !------------------------------------------------------------------------!
  126. :@EXIT   !  CALLED FOR THE CURRENT WORLD BY THE CONTROL SCRIPT
  127. !------------------------------------------------------------------------!
  128.  
  129.   ! Handle exit text if any !
  130.   if world.exittext(world.door) >= 0 then
  131.     readtext( world.exittext(world.door) );
  132.     if world.exittextswitch(world.door) then
  133.       world.exittext(world.door) = -1; ! Never Again.. !
  134.     endif;
  135.   endif;
  136.  
  137.   ! If it's OK to exit the current world through the
  138.   ! door indicated here, you go ahead and issue the
  139.   ! ENTER() command followed by CONTINUE to tell the
  140.   ! driver to go ahead and load the next world !
  141.  
  142.   enter( world.door );
  143.   CONTINUE;
  144.                                      
  145.   ! if you wanted to prevent someone from taking this
  146.   ! door, you would not call ENTER and would call 
  147.   ! STOP to finish this script
  148.